//------------------------------------------------------------------------------ 
//  <copyright file="ImageEdgel.h" company="Microsoft Corporation">
// The MIT License (MIT)
// 
// Copyright (c) 2014, Microsoft Corporation
// 
// Permission is hereby granted, free of charge, to any person obtaining a copy
//  of this software and associated documentation files (the "Software"), to deal
//  in the Software without restriction, including without limitation the rights
//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
//  copies of the Software, and to permit persons to whom the Software is
//  furnished to do so, subject to the following conditions:
// 
// The above copyright notice and this permission notice shall be included in
//  all copies or substantial portions of the Software.
// 
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
//  THE SOFTWARE.
//  </copyright>
//------------------------------------------------------------------------------
#pragma once
#include <vt_edgedetect.h>
#include <vt_linedetector.h>


using namespace System;
using namespace System::Collections::Generic;

namespace Microsoft 
{
    namespace Robotics 
    {
        namespace Vision 
        {
			/// <summary>
			/// Managed version of the edge segment returned by VisionTools
			/// </summary>
            public ref struct ImageEdgel
            {
				/// <summary> X coordinate (sub-pixel) of edge position </summary>
				double CenterX;
					
				/// <summary> Y coordinate (sub-pixel) of edge position </summary>
				double CenterY;         

				/// <summary> X component of normal vector (indicating orientation) </summary>
				double NormalX;
					
				/// <summary> Y component of normal vector (indicating orientation) </summary>
				double NormalY;
					     
				/// <summary>  Orientation, as angle (degrees) </summary>
				double Theta;        

				/// <summary> Length of edgel within 1x1 rect </summary>
				double EdgelLengthWithin1x1Rect;   

				/// <summary> strength of edgel (local gradient magnitude SQUARED) </summary>
				double Strength;     

				/// <summary> In case of steerable filters this is the phase angle (degrees) </summary>
				double Phi;			

				/// <summary> Length of line (estimated from ellipsoid) </summary>
				double LineLength;  

				/// <summary> Estimated std. dev. of edgel noise </summary>
				double Sigma;        

				/// <summary> X coordinate of end point 1 of the edgel </summary>
				double Endpoint1X;

				/// <summary> Y coordinate of end point 1 of the edgel </summary>
				double Endpoint1Y;

				/// <summary> X coordinate of end point 2 of the edgel </summary>
				double Endpoint2X;

				/// <summary> Y coordinate of end point 2 of the edgel </summary>
				double Endpoint2Y;

				/// <summary> Curvature of the line joining the current point and previous
				/// point on the curve </summary>
				double Curvature;

				/// <summary> Construct from a native version </summary> 
				ImageEdgel(vt::EdgeSegment *pEdgeSegment)
				{
					this->CenterX = pEdgeSegment->x;
					this->CenterY = pEdgeSegment->y;
					this->NormalX = pEdgeSegment->n_x;
					this->NormalY = pEdgeSegment->n_y;
					this->Theta = pEdgeSegment->theta;
					this->EdgelLengthWithin1x1Rect = pEdgeSegment->length;
					this->Strength = pEdgeSegment->strength;
					this->Phi = pEdgeSegment->phi;	
					this->LineLength = pEdgeSegment->lineLength;
					this->Sigma = pEdgeSegment->sigma;
					this->Endpoint1X = pEdgeSegment->endpoint1.x;
					this->Endpoint1Y = pEdgeSegment->endpoint1.y;
					this->Endpoint2X = pEdgeSegment->endpoint2.x;
					this->Endpoint2Y = pEdgeSegment->endpoint2.y;
					this->Curvature = pEdgeSegment->curvature;
				}
            };
        }
    }
}
